package com.jichangxiu.framework.entity.bo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jichangxiu.common.entity.rule.PowerRule;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;

import java.io.Serializable;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SecurityPower implements GrantedAuthority, Serializable {

    private static final long serialVersionUID = 1L;

    private PowerRule powerRule;

    public String getPowerId() {
        return powerRule.getPowerId();
    }

    public String getPowerCode() {
        return powerRule.getPowerCode();
    }

    @Override
    @JsonIgnore
    public String getAuthority() {
        return getPowerCode();
    }

}
 